
// 退出重置数据
// 主要是清除menu的路由和token以及用户信息

import { storge } from '@/utils'
import Router from '@/router'
import context from "@/main"
import { mapMutations } from "vuex"
const { SET_MENU } = mapMutations(["SET_MENU"])

// 重置数据
const clearData = () => {
    storge.clearSessionStorage('token')
    storge.clearSessionStorage('user')
    Router.replace({
        path: '/login'
    })
    SET_MENU.apply(context, [[]])
    const { routes } = Router.options
    routes.splice(3, 1)
    routes[2].children = []
    Router.addRoutes(routes)
}

export { clearData }